package com.thrustmaker.pdftest;

import java.io.FileOutputStream;
import java.net.URL;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;

import com.itextpdf.text.Document;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.PdfWriter;

public class PDFTestActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        createPDF();
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("Pdf created");
        alertDialog.setMessage("some text");
        
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub

			}
		});
        alertDialog.show();
    }

	private void createPDF() {
		Document document = new Document();

	    try {
	        PdfWriter.getInstance(document,
	                new FileOutputStream("/data/imagesrc/Image.pdf"));
	        document.open();

	        Image image1 = Image.getInstance("/data/imagesrc/mohit_pic.jpg");
	        document.add(image1);


	        document.close();
	    } catch(Exception e){
	      e.printStackTrace();
	    }
		
	}
}